import 'dart:async';
import 'package:flutter/services.dart';

class HoneywellScanner {
  HoneywellScanner._() {
    _channel.setMethodCallHandler(_onMethodCall);
  }
  static final HoneywellScanner _instance = HoneywellScanner._();
  factory HoneywellScanner() => _instance;

  static const _METHOD_CHANNEL = "honeywellscanner";
  static const _GET_CODE = "getCode";

  static const MethodChannel _channel = MethodChannel(_METHOD_CHANNEL);

  void Function(String code)? getCode;

  Future<void> _onMethodCall(MethodCall call) async {
    if (call.method == _GET_CODE) {
      try {
        getCode?.call(call.arguments);
      } catch (e) {
        print(e);
      }
    }
  }
}
